home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / info < prev    next >
Encoding:
Text File  |  2010-11-16  |  1.3 KB  |  59 lines

  1. # bash completion for info
  2.  
  3. have info &&
  4. _info()
  5. {
  6.     local cur i infopath
  7.  
  8.     COMPREPLY=()
  9.     _get_comp_words_by_ref cur
  10.  
  11.     _expand || return 0
  12.  
  13.     # default completion if parameter contains /
  14.     if [[ "$cur" == */* ]]; then
  15.         _filedir
  16.         return 0
  17.     fi
  18.  
  19.     infopath='/usr/share/info'
  20.  
  21.     if [ "${INFOPATH: -1:1}" == ':' ]; then
  22.         infopath=${INFOPATH}${infopath}
  23.     elif [ ${INFOPATH:+set} ]; then
  24.         infopath=$INFOPATH
  25.     fi
  26.  
  27.     infopath=$infopath:
  28.     if [ -n "$cur" ]; then
  29.         infopath="${infopath//://$cur* }"
  30.     else
  31.         infopath="${infopath//:// }"
  32.     fi
  33.  
  34.     # redirect stderr for when path doesn't exist
  35.     COMPREPLY=( $( eval command ls "$infopath" 2>/dev/null ) )
  36.     # weed out directory path names and paths to info pages
  37.     COMPREPLY=( ${COMPREPLY[@]##*/?(:)} )
  38.     # weed out info dir file
  39.     for (( i=0 ; i < ${#COMPREPLY[@]} ; ++i )); do
  40.         if [ "${COMPREPLY[$i]}" == 'dir' ]; then
  41.             unset COMPREPLY[$i];
  42.         fi;
  43.     done
  44.     # strip suffix from info pages
  45.     COMPREPLY=( ${COMPREPLY[@]%.@(gz|bz2|xz|lzma)} )
  46.     COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ) )
  47.  
  48.     return 0
  49. } &&
  50. complete -F _info -o filenames info
  51.  
  52. # Local variables:
  53. # mode: shell-script
  54. # sh-basic-offset: 4
  55. # sh-indent-comment: t
  56. # indent-tabs-mode: nil
  57. # End:
  58. # ex: ts=4 sw=4 et filetype=sh
  59.